# PyInstaller 打包脚本 - 打包为 Tkinter 桌面应用
# 使用方法: 在 PowerShell 中运行此脚本
# 如果遇到执行策略问题，运行: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Write-Host "========================================" -ForegroundColor Cyan
Write-Host "游戏集合中心 - PyInstaller 打包脚本" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""

# 检查 PyInstaller 是否安装
$pyinstaller = python -m pip show pyinstaller 2>$null
if (-not $pyinstaller) {
    Write-Host "⚠️  PyInstaller 未安装，正在安装..." -ForegroundColor Yellow
    python -m pip install pyinstaller
}

Write-Host ""
Write-Host "🔨 开始打包 Tkinter 应用..." -ForegroundColor Green
Write-Host ""

# 打包命令
$pyinstaller_args = @(
    "--onedir",
    "--windowed",
    "--name", "游戏集合中心",
    "--icon=icon.png",
    "--add-data", "game;game",
    "--add-data", "assets;assets",
    "--add-data", "games_config.json;.",
    "--add-data", "path_utils.py;.",
    "index.py"
)

pyinstaller @pyinstaller_args

Write-Host ""
Write-Host "✅ 打包完成！" -ForegroundColor Green
Write-Host ""
Write-Host "📁 输出目录: dist\游戏集合中心\" -ForegroundColor Cyan
Write-Host "🚀 运行程序: dist\游戏集合中心\游戏集合中心.exe" -ForegroundColor Cyan
Write-Host ""
Write-Host "按任意键继续..." -ForegroundColor Yellow
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
